﻿/*
* Copyright (c) 2010-2012 Tesla Engine Group
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

using Tesla.Math;

namespace Tesla.Input {
    /// <summary>
    /// Represents the state of the mouse, e.g. where the cursor is located on the screen (client coordinates), and what buttons are pressed.
    /// </summary>
    public struct MouseState {

        private int _x;
        private int _y;
        private int _wheel;
        private ButtonState _leftButton;
        private ButtonState _rightButton;
        private ButtonState _middleButton;
        private ButtonState _xb1;
        private ButtonState _xb2;

        /// <summary>
        /// Initializes a new instance of the <see cref="MouseState"/> struct.
        /// </summary>
        /// <param name="x">The x (horizontal) position of the mouse. Typically these are client coordinates.</param>
        /// <param name="y">The y (verticaly) position of the mouse. Typically these are client coordinates.</param>
        /// <param name="scrollWheel">The scroll wheel value.</param>
        /// <param name="leftButton">The left button state.</param>
        /// <param name="rightButton">The right button state.</param>
        /// <param name="middleButton">The middle button state.</param>
        /// <param name="xButton1">The XButton1 state.</param>
        /// <param name="xButton2">The XButton2 state.</param>
        public MouseState(int x, int y, int scrollWheel, ButtonState leftButton, ButtonState rightButton,
            ButtonState middleButton, ButtonState xButton1, ButtonState xButton2) {
            _x = x;
            _y = y;
            _wheel = scrollWheel;
            _leftButton = leftButton;
            _rightButton = rightButton;
            _middleButton = middleButton;
            _xb1 = xButton1;
            _xb2 = xButton2;
        }

        /// <summary>
        /// Gets the position of the mouse.
        /// </summary>
        public Vector2 Position {
            get {
                return new Vector2(_x, _y);
            }
        }

        /// <summary>
        /// Gets the x (horizontal) coordinate of the mouse position.
        /// </summary>
        public int X {
            get {
                return _x;
            }
        }

        /// <summary>
        /// Gets the y (vertical) coordinate of the mouse position.
        /// </summary>
        public int Y {
            get {
                return _y;
            }
        }

        /// <summary>
        /// Gets the mouse scroll wheel value.
        /// </summary>
        public int ScrollWheelValue {
            get {
                return _wheel;
            }
        }

        /// <summary>
        /// Gets the state of the left mouse button.
        /// </summary>
        public ButtonState LeftButton {
            get {
                return _leftButton;
            }
        }

        /// <summary>
        /// Gets the state of the right mouse button.
        /// </summary>
        public ButtonState RightButton {
            get {
                return _rightButton;
            }
        }

        /// <summary>
        /// Gets the state of the middle mouse button.
        /// </summary>
        public ButtonState MiddleButton {
            get {
                return _middleButton;
            }
        }

        /// <summary>
        /// Gets the state of the XButton1.
        /// </summary>
        public ButtonState XButton1 {
            get {
                return _leftButton;
            }
        }

        /// <summary>
        /// Gets the state of the XButton2.
        /// </summary>
        public ButtonState XButton2 {
            get {
                return _leftButton;
            }
        }
    }
}
